package com.zj.leetcode.medium.binarySearch;

/**
 * @program: algorithm
 * @description: H 指数 II
 * 275 h-index-ii
 * @author: Zhang Bo
 * @create: 2022-01-14 17:05
 **/
public class HIndexIi {
    public static void main(String[] args) {
        Solution solution = new HIndexIi().new Solution();
    }

    //leetcode submit region begin(Prohibit modification and deletion)
    class Solution {
        public int hIndex(int[] citations) {

            int l = 0;
            int r = citations.length - 1;
            int mid = (r - l) / 2 + l;

            while (l <= r){
                if(citations[mid] >= citations.length - mid){
                    r = mid - 1;
                }else {
                    l = mid + 1;
                }
            }
            return citations.length - l;
        }
    }
//leetcode submit region end(Prohibit modification and deletion)

}
